package com.ruoyi.archive.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.archive.domain.SDemobilizationSoldier;
import com.ruoyi.archive.service.ISDemobilizationSoldierService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 复员军人信息Controller
 * 
 * @author Allen
 * @date 2021-09-29
 */
@RestController
@RequestMapping("/archive_info/demobilization_soldier")
public class SDemobilizationSoldierController extends BaseController
{
    @Autowired
    private ISDemobilizationSoldierService sDemobilizationSoldierService;

    /**
     * 查询复员军人信息列表
     */
    @PreAuthorize("@ss.hasPermi('archive_info:demobilization_soldier:list')")
    @GetMapping("/list")
    public TableDataInfo list(SDemobilizationSoldier sDemobilizationSoldier)
    {
        startPage();
        List<SDemobilizationSoldier> list = sDemobilizationSoldierService.selectSDemobilizationSoldierList(sDemobilizationSoldier);
        return getDataTable(list);
    }

    /**
     * 导出复员军人信息列表
     */
    @PreAuthorize("@ss.hasPermi('archive_info:demobilization_soldier:export')")
    @Log(title = "复员军人信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SDemobilizationSoldier sDemobilizationSoldier)
    {
        List<SDemobilizationSoldier> list = sDemobilizationSoldierService.selectSDemobilizationSoldierList(sDemobilizationSoldier);
        ExcelUtil<SDemobilizationSoldier> util = new ExcelUtil<SDemobilizationSoldier>(SDemobilizationSoldier.class);
        return util.exportExcel(list, "复员军人信息数据");
    }

    /**
     * 获取复员军人信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive_info:demobilization_soldier:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(sDemobilizationSoldierService.selectSDemobilizationSoldierById(id));
    }

    /**
     * 新增复员军人信息
     */
    @PreAuthorize("@ss.hasPermi('archive_info:demobilization_soldier:add')")
    @Log(title = "复员军人信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SDemobilizationSoldier sDemobilizationSoldier)
    {
        return toAjax(sDemobilizationSoldierService.insertSDemobilizationSoldier(sDemobilizationSoldier));
    }

    /**
     * 修改复员军人信息
     */
    @PreAuthorize("@ss.hasPermi('archive_info:demobilization_soldier:edit')")
    @Log(title = "复员军人信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SDemobilizationSoldier sDemobilizationSoldier)
    {
        return toAjax(sDemobilizationSoldierService.updateSDemobilizationSoldier(sDemobilizationSoldier));
    }

    /**
     * 删除复员军人信息
     */
    @PreAuthorize("@ss.hasPermi('archive_info:demobilization_soldier:remove')")
    @Log(title = "复员军人信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sDemobilizationSoldierService.deleteSDemobilizationSoldierByIds(ids));
    }
}
